package com.situ.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.situ.service.OrdersService;
import com.situ.entity.Orders;
import com.situ.test.*;

import java.util.List;

/**
 * Orders的路由接口服务
 * 
 * @author胡文
 *
 */
//
@Api(description = "Orders模块接口说明")
@RestController
public class OrdersController {

	/** OrdersService服务 */
	@Autowired
	private OrdersService ordersService;
	
	/**
	 * 查询所有Orders数据的方法
	 * @param value
	 * @return
	 */
@ApiOperation("查询所有Orders数据的方法")
	@GetMapping(value = "/Orders/query", produces = {"application/json;charset=UTF-8"})
	public ResponseData query(Orders value) {

		return ResponseData.ok().putDataValue("list",ordersService.find(value));
	}
	
	
	/**
	 * 插入Orders属性不为空的数据方法
	 * 
	 * @return
	 */
@ApiOperation("插入Orders属性不为空的数据方法")
	@PostMapping(value = "/Orders/save")
	public ResponseData save(Orders value) {
		return ResponseData.ok().putDataValue("obj", ordersService.saveNotNull(value));
	}
	


    //带分页的查询全部
    @ApiOperation("带分页的条件模糊查询")
    @GetMapping(value = "/Orders/queryPage", produces = {"application/json;charset=UTF-8"})
    public ResponseData queryPage(Orders value,
                            @ApiParam("第几页")
                             @RequestParam(defaultValue = "1",required = false) int pageNum ,
                                  @ApiParam("每页多少条")
                             @RequestParam(defaultValue = "10",required = false) int pageSize) {

	 PageHelper.startPage(pageNum, pageSize);
        List<Orders> list = ordersService.find2(value);
    PageInfo pageInfo = new PageInfo<Orders>(list,7);
        return ResponseData.ok()
        .putDataValue("pageInfo",pageInfo);
   }

}
